package com.qs.controller;


import com.qs.model.vo.OrderInfoVo;
import com.qs.response.Response;
import com.qs.service.IUserGoodsLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户购买商品历史表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-03-31
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/user/goods/log")
public class UserGoodsLogController {

    private final IUserGoodsLogService service;

    /**
     * 待发货订单查询
     * @param userId
     * @return
     */
    @GetMapping("/wait/deliver/{userId}")
    public Response queryWaitDeliver(@PathVariable("userId") Integer userId){
        log.info("id为{}的用户正在进行待发货订单数据查询....",userId);
        List<OrderInfoVo> list = service.queryWaitDeliver(userId);
        log.info("id为{}的用户正在进行待发货订单数据查询请求成功！",userId);
        return Response.success(list);
    }

    /**
     * 查询当前用户的待发货订单数量
     * @param userId
     * @return
     */
    @GetMapping("/wait/deliver/count/{userId}")
    public Response queryWaitDeliverCount(@PathVariable("userId") Integer userId) {
        log.info("id为{}的用户正在进行待发货订单数量查询请求...",userId);
        int count = service.queryWaitDeliverCount(userId);
        log.info("id为{}的用户正在进行待发货订单数量查询成功",userId);
        return Response.success(count);
    }

    /**
     * 待收货订单查询
     * @param userId
     * @return
     */
    @GetMapping("/wait/receive/{userId}")
    public Response queryWaitReceive(@PathVariable("userId") Integer userId){
        log.info("id为{}的用户正在进行待收货订单数据查询....",userId);
        List<OrderInfoVo> list = service.queryWaitReceive(userId);
        log.info("id为{}的用户正在进行待收货订单数据查询请求成功！",userId);
        return Response.success(list);
    }

    /**
     * 查询当前用户的待收货订单数量
     * @param userId
     * @return
     */
    @GetMapping("/wait/receive/count/{userId}")
    public Response queryWaitReceiveCount(@PathVariable("userId") Integer userId) {
        log.info("id为{}的用户正在进行待收货订单数量查询请求...",userId);
        int count = service.queryWaitReceiveCount(userId);
        log.info("id为{}的用户正在进行待收货订单数量查询成功",userId);
        return Response.success(count);
    }

    /**
     * 待评价订单查询
     * @param userId
     * @return
     */
    @GetMapping("/wait/comment/{userId}")
    public Response queryWaitComment(@PathVariable("userId") Integer userId){
        log.info("id为{}的用户正在进行待评价订单数据查询....",userId);
        List<OrderInfoVo> list = service.queryWaitComment(userId);
        log.info("id为{}的用户正在进行待评价订单数据查询请求成功！",userId);
        return Response.success(list);
    }

    /**
     * 查询当前用户的待评价订单数量
     * @param userId
     * @return
     */
    @GetMapping("/wait/comment/count/{userId}")
    public Response queryWaitCommentCount(@PathVariable("userId") Integer userId) {
        log.info("id为{}的用户正在进行待评价订单数量查询请求...",userId);
        int count = service.queryWaitCommentCount(userId);
        log.info("id为{}的用户正在进行待评价订单数量查询成功",userId);
        return Response.success(count);
    }

}
